/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef TIMELINE_SERVICE_H
#define TIMELINE_SERVICE_H

#include <memory>
#include <iremote_object.h>
#include <system_ability.h>

#include "timeline_srv_stub.h"
#include "itimeline_callback.h"
#include "timeline_data_utils.h"
#include "timeline_manager.h"
#include "timeline_singleton.h"
#include "timeline_rdb_manager.h"

// #include "timeline_rdb.h"

namespace OHOS {
namespace Msdp {
class TimelineService final : public SystemAbility, public TimelineSrvStub {
    DECLARE_SYSTEM_ABILITY(TimelineService)
    DECLARE_DELAYED_SP_SINGLETON(TimelineService);
public:
    virtual void OnStart() override;
    virtual void OnStop() override;

    void Subscribe(const TimelineDataUtils::TimelineArea& area, const sptr<ITimelineCallback>& callback) override;
    void UnSubscribe(const TimelineDataUtils::TimelineArea& area, const sptr<ITimelineCallback>& callback) override;
    bool IsServiceReady();
    bool SetPositionState(int32_t homevalue, int32_t companyvalue) override;
    bool SetHomePosition(double longitude, double latitude)override;
    bool SetCompanyPosition(double longitude, double latitude)override;
    bool SetSleepTime(int32_t sleeptime, int32_t wakeuptime)override;
    bool SetRestTime(int32_t resttimestart, int32_t resttimeend)override;
    bool SetWorkTime(int32_t worktimestart, int32_t worktimeend)override;
    TimelineDatabaseInfo::ForcecastPosition GetForcecast(uint32_t time)override;
    // bool GetHomePosition()override;
    // bool GetCompanyPosition()override;
    uint32_t GetSleepTime()override;
    uint32_t GetWakeupTime()override;
    uint32_t GetRestTimeStart()override;
    uint32_t GetRestTimeEnd()override;
    uint32_t GetWorkTimeStart()override;
    uint32_t GetWorkTimeEnd()override;
    std::shared_ptr<TimelineManager> GetTimelineManager();
    std::shared_ptr<TimelineRdbManager> GetTimeRdbManager() const
    {
        return timelinerdbmgr_;
    }
private:
    bool Init();
    bool ready_ = false;
    std::shared_ptr<TimelineManager> timelineManager_;
	std::shared_ptr<TimelineRdbManager> timelinerdbmgr_;
};
} // namespace Msdp
} // namespace OHOS
#endif // TIMELINE_SERVICE_H
